#include "stdafx.h"

//
// DPanicButtonEvents
//

STDMETHODIMP_( void ) CPanicButtonEventSink2::LidStatusChange( VARIANT_BOOL LidOpen ) {
	debug( L"CPanicButtonEventSink2::LidStatusChange: tid 0x%lX\n", GetCurrentThreadId( ) );

	if ( hwndNotify ) {
		::PostMessage( hwndNotify, WMR_UPDATE_LID, LidOpen ? true : false, 0 );
	}
}

STDMETHODIMP_( void ) CPanicButtonEventSink2::ButtonStatusChange( VARIANT_BOOL ButtonPressed ) {
	debug( L"CPanicButtonEventSink2::ButtonStatusChange: tid 0x%lX\n", GetCurrentThreadId( ) );

	if ( hwndNotify ) {
		::PostMessage( hwndNotify, WMR_UPDATE_BUTTON, ButtonPressed ? true : false, 0 );
	}
}

//
// IPanicButtonEventSink2
//

STDMETHODIMP CPanicButtonEventSink2::put_NotifyWindow( IN HWND hwnd ) {
	hwndNotify = hwnd;
	return S_OK;
}

STDMETHODIMP CPanicButtonEventSink2::get_NotifyWindow( OUT HWND* phwnd ) {
	if ( NULL == phwnd ) {
		return E_POINTER;
	}

	*phwnd = hwndNotify;
	return S_OK;
}
